console.log(1)

setTimeout(() => {
  console.log(2)
}, 0)

new Promise((resolve) => {
    console.log(3)
    resolve(4)
}).then((a) => {
    console.log(a)
    Promise.resolve().then(() => console.log(9)) // 
    return Promise.resolve().then(() => console.log(7))
})

console.log(5)






for (var i=0; i<=5; i++) {
  setTimeout(function(){
      console.log(i)
  }, 1000)
}

for(var i=0; i<=5; i++){
  (function(){
      setTimeout(function(){console.log(i)}, 1000)
  })()
}

for(var i = 0; i<=5; i++){
  (function(j){
      setTimeout(function(){console.log(i)}, 1000)
  })(i)
}